package com.peaker.advertisingpro.adapter

import android.graphics.Bitmap
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.peaker.advertisingpro.R

/**
 *  @ 作者 CODE_LYF
 *  @ 时间   2021/4/1.
 *  代码人生
 */
class ImageAdapter(var list: ArrayList<Bitmap>) : RecyclerView.Adapter<ImageAdapter.ViewHolder>() {

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
         var img_item: ImageView = itemView.findViewById(R.id.img_item)

    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder(
        LayoutInflater.from(parent.context).inflate(
            R.layout.img_item, parent, false
        )
    )

    override fun getItemCount(): Int = list.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
//        holder.img_item.setImageBitmap(list[position])
        //                imageHolder.imageView.setImageResource(data.imageRes);
        Glide.with(holder.itemView)
            .load(list[position]) //
            .into(holder.img_item)

    }


}